define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'project/order/index' + location.search,
                    del_url: 'project/order/del',
                    table: 'project_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'order.id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true,},
                        { field: 'id', title: __('Id'), sortable: false },
                        { field: 'project.title', title: __('project'), operate: 'LIKE' },
                        { field: 'business.nickname', title: __('business') , operate: false},
                        { field: 'total', title: __('total') , operate: false},
                        { field: 'status', title: __('Ostatus'), searchList: { "0": __('未开始'), "1": __('已开始'), "2": __('已结束') }, formatter: Table.api.formatter.status },
                        { field: 'createtime', title: __('Ocreatetime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                        { field: 'comment', title: __('comment') , operate: false},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate,
                            
                        }
                    ]
                ],
                escape: false,
                // search:false,
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        del: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        },
    };
    return Controller;
});